﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpApplication.Expand
{
    public static class PageHeler
    {

        public static PageValue<T> PageMethod<T>(List<T> list,int pageIndex,int pagesize)
        {

           var values=   list.Skip((pageIndex - 1) * pagesize).Take(pagesize).ToList();
            long count = list.LongCount();//计算出了总条数
            long pageCount = (long)Math.Ceiling(count * 1.0 / pagesize);//计算出总页数
            return new PageValue<T> (values, pageCount,count);
        }
    }

    public class PageValue<T>
    {
        public List< T> Value { get; set; }
        public long count { get; set; }
        public long pageCount { get; set; }

        public PageValue(List< T> value, long count, long pageCount)
        {
            Value = value;
            this.count = count;
            this.pageCount = pageCount;
        }
    }
}
